package Class.Advance.InnerClass.AnonymousInternalClass;

public class MainClass {
    public void test1(){
        new Example1(){
            @Override
            public void testMethod() {
                System.out.println("匿名内部类实现接口");
            }
        };

    }

    public void test2(){
        //可以将匿名内部类作为函数的参数，甚至可以实现多态
        testMethod(new Example2(){
            @Override
            public  void eat(){
                System.out.println("eat2");
            }
        });
    }

    public static void testMethod(Example2 example){
        example.eat();
    }
}
